home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 171 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: stdc.demon.co.uk!clive
  2. From: clive@stdc.demon.co.uk (Clive D.W. Feather)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Double-character operators
  5. Date: Tue, 23 Jan 1996 07:15:54 GMT
  6. Organization: Demon Internet Limited (personal account)
  7. Message-ID: <DLMHIK.8v9@stdc.demon.co.uk>
  8. References: <4e17uk$g3@kocrsv08.delcoelect.com>
  9. Reply-To: clive@demon.net
  10. X-NNTP-Posting-Host: stdc.demon.co.uk
  11.  
  12. In article <4e17uk$g3@kocrsv08.delcoelect.com>,
  13. Richard F. Smiley <c2xrfs@eng.delcoelect.com> wrote:
  14. > Is the program fragment
  15. >    if ( Boolean_A  & =  0x0020 )
  16. > legal?  Specifically, should the three-character sequence  "& ="  be
  17. > treated as representing the two-character operator  "&="?  
  18.  
  19. No to both questions.
  20.  
  21. > As I understand the standard (ISO section 5.1.1.2, phase 7), the "&"
  22. > is converted into one token, and the "=" is converted into another. 
  23. > This then precludes treating them as one operator, and the program
  24. > fragment is illegal.  
  25.  
  26. Correct.
  27.  
  28. > However, a compiler I respect instead treats this as a legal fragment
  29. > involving the "&=" operator.
  30.  
  31. This is permitted, provided at least one diagnostic is produced along
  32. the way.
  33.  
  34. > (The program fragment
  35. > was caused by a bad macro definition.  If the compiler had complained,
  36. > we would have found the problem earlier.)
  37.  
  38. The &= must exist before the preprocessor works - it can't be generated
  39. by, for example:
  40.  
  41.     #define EQ =
  42.  
  43.     ... &EQ
  44.  
  45. unless you use the ## preprocessor operator, which generates new
  46. tokens.
  47.  
  48. -- 
  49. Clive D.W. Feather                       | If you lie to the compiler,
  50. cdwf@cityscape.co.uk   (work, preferred) | it will get its revenge.
  51. clive@stdc.demon.co.uk (home)            |   - Henry Spencer
  52.